﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ManageATrois
{
    public class ProfileManager
    {

        private const int NUM_SUPPORTED_PROFILES = 20;

        public Profile[] profiles = new Profile[NUM_SUPPORTED_PROFILES];
        public int profileCount = 0;
        public int selectedIndex = -1;

        public int CreateNewEmptyProfile()
        {
            if (profileCount >= NUM_SUPPORTED_PROFILES)
                return -1;

            Profile prof = new Profile();
            prof.Name = "new..";
            prof.SourceFolder = "not set..";
            prof.DestFolder = "not set..";

            profiles[profileCount] = prof;
            profileCount++;

            return (profileCount - 1);
        }

        public void SelectProfile( int index )
        {
            selectedIndex = index;
        }

        public void DeleteProfile(int index)
        {
            if (profileCount == 0)
                return;
            else if (profileCount == 1)
            {
                profiles[0] = null;
                profileCount = 0;
                return;
            }

            for (int i = 0; i < profileCount; i++)
            {
                if (i >= index)
                {
                    if (i < (NUM_SUPPORTED_PROFILES - 1))
                        profiles[i] = profiles[i + 1];
                    else
                        profiles[NUM_SUPPORTED_PROFILES - 1] = null;
                }
            }

            profileCount--;
        }
    }
}
